//
// Created by xili on 2024/9/29 10:33.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int minimumCost(vector<int> &nums) {
        int fi = INT32_MAX, se = INT32_MAX;
        int n = nums.size();
        for (int i = 1; i < n; i++) {
            if (fi > nums[i]) {
                se = fi;
                fi = nums[i];
            } else if (se > nums[i]) {
                se = nums[i];
            }
        }
        return nums[0] + fi + se;
    }
};